package com.redpack.redpost.util.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.redpack.redpost.connection.RedpostConexion;
import com.redpack.redpost.util.to.*;

public class EstatusArriboDao {

	
	public static List getEstatusArribo() throws Exception {
		
		Connection conn = RedpostConexion.openConnection( ) ;
		conn.setAutoCommit( false ) ;
		PreparedStatement ps = null ;
		ResultSet rs = null ;
		List estatusArribo = new ArrayList(); 
		String sql = "" ;
		
		try{			
			sql = "select * from redpost.tbl_estatus_arribo;";
			ps = conn.prepareStatement( sql ) ;
			rs = ps.executeQuery();

			
			while (rs.next()) {
				EstatusArriboTo row = new EstatusArriboTo();
				
				row.setCve_Estatus_Arribo(rs.getInt("cve_Estatus_Arribo"));
				row.setDescripcion(rs.getString("descripcion"));

				estatusArribo.add( row );
			}
			
			conn.commit( ) ;
			ps.close( ) ;
			conn.close( ) ;
			
			return estatusArribo ;
			
		}catch ( Exception e ) {
			e.printStackTrace( ) ;
			return estatusArribo = null ;
		} finally {
	        if (conn != null) {
	            conn.close();
	        }
			
		}
	}	
	
}
